import axios from "axios";
const httpUrl = "http://218.202.240.118:8085";
const objectToQuery = function () {
	let obj = arguments[0];
	let prefix = arguments[1];
	if (typeof obj !== "object") return "";
	const attrs = Object.keys(obj);
	return attrs.reduce((query, attr, index) => {
		// 判断是否是第一层第一个循环
		if (index === 0 && !prefix) query += "?";
		if (typeof obj[attr] === "object") {
			const subPrefix = prefix ? `${prefix}[${attr}]` : attr;
			query += this.objectToQuery(obj[attr], subPrefix);
		} else {
			if (prefix) {
				query += `${prefix}[${attr}]=${obj[attr]}`;
			} else {
				query += `${attr}=${obj[attr]}`;
			}
		}
		// 判断是否是第一层最后一个循环
		if (index !== attrs.length - 1) query += "&";
		return query;
	}, "");
}
// 获取客户列表
export const listCustomer = params => {
    return axios.get(httpUrl + "/order/listCustomer"+objectToQuery(params));
};
// 获取版本号列表
export const listVersion = params => {
    return axios.get(httpUrl + "/order/listVersion"+objectToQuery(params));
};
// 获取产品列表
export const listProduct = params => {
    return axios.get(httpUrl + "/order/listProduct"+objectToQuery(params));
};
// 获取查询列表
export const list = params => {
    return axios.get(httpUrl + "/order/list"+objectToQuery(params));
};